package com.study.seckill.web.api;

import com.study.dto.UserDTO;
import com.study.seckill.entity.CourseSeckillOrder;
import com.study.seckill.service.CourseService;
import com.study.util.ResponseResult;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Component;

/**
 * @ClassName: Rabbithandler
 * @Author: wYin
 * @Date: 2022/3/11 16:39
 */
@RabbitListener(queues = {"wYin-dead-queue"})
@Component
public class RabbitEmailHandler {
    @Autowired
    private JavaMailSender javaMailSender;

    @RabbitHandler
    public void receiving(CourseSeckillOrder courseSeckillOrder){
        System.out.println("消息是："+courseSeckillOrder);
        SimpleMailMessage message = new SimpleMailMessage();
        message.setFrom("2443551575@qq.com");
        message.setTo("wyin12@qq.com");
        message.setSubject("测试邮件");
        String html = "<html><body><h4>订单编号为："+courseSeckillOrder.getOrderNumber()+"下单时间是："+courseSeckillOrder.getOrderTime()+"</h4" +
                "></body" +
                "></html>";
        message.setText(html);
        javaMailSender.send(message);

    }
}
